{%insert header.tpl%}
<script type="text/javascript" src="{% $THEME_URL %}/js/tiny_mce/jquery.tinymce.js"></script>
{%insert top.tpl%}
{%insert breadcrumbs.tpl%}
<script language="javascript" type="text/javascript">
	function show_tab(tab){
		var t = $(tab);
		t.parent().next().children().hide();
		$("#"+tab.id.replace("_tab","")+"_pane").show();
		t.parent().children().removeClass("active");
		t.addClass("active");
		$.cookie("<?php echo $this->PAGE->Name(); ?>_"+t.parent().attr("id"),t.attr("id"));
	}

	$(document).one("ready",function(){
		$(".tabs").each(function(){
			cv = $.cookie("<?php echo $this->PAGE->Name(); ?>_"+this.id);
			if (cv)
				show_tab($("#"+cv)[0]);
			else
				show_tab($(".tab",this)[0]);
		});
	});
</script>
<link type="text/css" href="{% $THEME_URL %}/css/product.css" rel="stylesheet" />
<div id="main_tabs" class="tabs">
<span id="item_tab" class="tab" onclick="javascript:show_tab(this);">Данные</span>
<span id="content_tab" class="tab" onclick="javascript:show_tab(this);">Страница</span>
</div>
<div class="panes">
<div class="pane" id="item_pane">
{%insert form.tpl%}
</div>
<div class="pane" id="content_pane">
{%if ItemPage%}
<form class="editor" method="post" enctype="multipart/form-data">
<input type="hidden" name="method" value="SavePage" />
<table class="page-section">
	<tr>
	<td>
{%with ItemPage%}
	<div class="page-info">
	<div><span class="label">Заголовок страницы</span><input class="property-value" type="text" name="pp[Title]" value="{@% q < Title %}" /></div>
	<div><span class="label">Имя для ссылок</span><input class="property-value" type="text" name="pp[Slug]" value="{% q < Slug %}" /></div>
	<div><span class="label">Опубликован</span><input class="property-value" type="checkbox" name="pp[IsPublished]"{%if IsPublished%} checked{%endif%} /></div>
	<div>
		<span class="label">Ссылка на страницу витрины</span>
		<a id="frontend-link"></a>
	</div>
	<div>
	<div id="page_texts" class="tabs">
	<span id="long_desc_tab" class="tab" onclick="javascript:show_tab(this);">Описание</span>
	<span id="short_desc_tab" class="tab" onclick="javascript:show_tab(this);">Краткое описание</span>
	<span id="meta_tab" class="tab" onclick="javascript:show_tab(this);">Мета</span>
	</div>
	<div class="panes">
		<div class="pane" id="long_desc_pane"><textarea class="wysiwyg property-value" type="text" name="pp[PageContents]">{% q < PageContents %}</textarea></div>
		<div class="pane" id="short_desc_pane" style="display:none;"><textarea class="wysiwyg property-value" type="text" name="pp[Snippet]">{% q < Snippet %}</textarea></div>
		<div class="pane" id="meta_pane" style="display:none;">
			<div><span class="label">Мета-описание</span><textarea class="property-value" type="text" name="pp[Description]">{% q < Description %}</textarea></div>
			<div><span class="label">Ключевые слова</span><textarea class="property-value" name="pp[Keywords]">{% q < Keywords %}</textarea></div>
		</div>
	</div>
	</div>
{%endwith%}
	</td>
	<td>
	<span class="label">Категории:</span>
	<div class="page-categories">
	{%iterate Categories as cat%}
	{%insert integral.category_node.tpl%}
	{%iterate%}
	</div>
	</td>
	</tr>
	</table>
<div class="btn-holder bottom-toolbar"><button type="submit">{% i < `Save` %}</button></div>
{%else%}
<form class="editor" method="post" enctype="multipart/form-data">
<input type="hidden" name="method" value="PublishItem" />
<span class="label">{% i < `Categories`%}:</span>
	<div class="page-categories">
	{%iterate Categories as cat%}
	{%insert integral.category_node.tpl%}
	{%iterate%}
	</div>
	<div class="btn-holder bottom-toolbar"><button type="submit">{% i < `Publish` %}</button></div>
{%endif%}
</form>	
</div>
</div>
<script language="javascript">
	$(document).ready(function(){
		$.getJSON("{@%FrontProductUrlQuery%}",function(data){
			$("#frontend-link").text(data).attr('href',data);
        });       				
	});
</script>
{%insert footer.tpl%}
